<?php 
include("include/connect.php");
if(isset($_GET['key']))
{
	$detail=mysql_query("select * from phim where maphim={$_GET['id']}");
	$de=mysql_fetch_array($detail);
	
	$daodien =mysql_fetch_array(mysql_query("select * from daodien where madaodien = {$de['madaodien']}"));
	$quocgia=mysql_fetch_array(mysql_query("select * from quocgia where maquocgia = {$de['maquocgia']}"));
	$nsx=mysql_fetch_array(mysql_query("select * from nhasx where mansx={$de['manhasx']}"));
	$chatluong=mysql_fetch_array(mysql_query("select * from chatluong where machatluong={$de['machatluong']}"));
	$chatluong_menu = mysql_fetch_array(mysql_query("select * from theloai where tentheloai='{$chatluong['tenchatluong']}'"));
	$chuyengu=mysql_fetch_array(mysql_query("select * from chuyenngu where machuyenngu={$de['machuyenngu']}"));
	$cn=mysql_fetch_array(mysql_query("select * from theloai where tentheloai='{$chuyengu['tenchuyenngu']}'"));
		
	$tl=mysql_query("select * from theloai,cttheloai where cttheloai.maphim={$_GET['id']} and cttheloai.matheloai=theloai.matheloai ");
	$dv=mysql_query("select * from dienvien,ctdienvien where ctdienvien.madienvien=dienvien.madienvien and ctdienvien.maphim ={$_GET['id']}");
	$t = mysql_fetch_array(mysql_query("select * from phim where maphim ={$_GET['id']}"));
	$tenphim = $t['tenphim'];
	$tapdautien=mysql_fetch_array(mysql_query("select * from phim where maphim <> {$_GET['id']} and tenphim = '{$tenphim}' limit 0,1"));
	
	$des=explode(".",preg_replace("/<img[^>]+\>/i", "(image) ", $de['gioithieu']));
?>
<span id="seo_description" style="display:none"> <?php echo $des[1] ;?></span>
<span id="seo_keywords" style="display:none"> Xem phim <?php echo $de['tenphim'];?></span>
<h1 class="ps_title"><?php echo $de['tenphim']?></h1>
<div class="ps_padding_10">
    <div class="clear"></div>
    <div class="large_thumbnail">
        <img itemprop="photo" src="<?php echo $de['linkanh'] ?>" alt="<?php echo $de['tenphim']?>" style="width:232px;height:299px">
    </div>
    <div class="info">
        <ul>
            <li><span class="title">Đạo diễn:</span><a class="no_title" href="index.php?keyword=<?php echo $daodien['tendaodien']?>" title="<?php echo $daodien['tendaodien']?>"><?php echo $daodien['tendaodien']?></a></li>
            <li><span class="title">Diễn viên:</span> 
            <?php
			while($dienvien=mysql_fetch_array($dv))
			{?>
            <a class="no_title" href="index.php?keyword=<?php echo $dienvien['tendienvien']?>" title="<?php echo $dienvien['tendienvien']?>"><?php echo $dienvien['tendienvien']?>,</a>
            <?php }?>
            </li>
            <li><span class="title">Nhà sản xuất:</span> <a class="no_title" href="index.php?keyword=<?php echo $nsx['tennsx']?>" title="<?php echo $nsx['tennsx']?>"><?php echo $nsx['tennsx']?></a></li>
            <li><span class="title">Quốc gia:</span> <a class="no_title" href="index.php?keyword=<?php echo $quocgia['tenquocgia'] ?>" title="<?php echo $quocgia['tenquocgia'] ?>"><?php echo $quocgia['tenquocgia'] ?></a></li>
            <li><span class="title">Thể loại:</span>
            	<?php while($theloai=mysql_fetch_array($tl))
				{?>
            	<a class="no_title" href="index.php?key=theloai&id=<?php echo $theloai['matheloai']?>&name=<?php echo $theloai['tentheloai']?>" title="<?php echo $theloai['tentheloai']?>"><?php echo $theloai['tentheloai']?>,</a>
                <?php }?>
            </li>
            <li><span class="title">Thời lượng:</span><?php echo $de['thoiluong'] ?></li>
            <li><span class="title">Chất lượng:</span> <a class="no_title" href="index.php?key=theloai&id=<?php echo $chatluong_menu['matheloai']?>" title="Phim <?php echo $chatluong_menu['tentheloai']?>"><?php echo $chatluong_menu['tentheloai']?></a></li>
            <li><span class="title">Chuyển ngữ:</span> 
            	<a class="no_title" href="index.php?key=theloai&id=<?php echo $cn['matheloai']?>" title="<?php echo $chuyengu['tenchuyenngu']?>"><?php echo $chuyengu['tenchuyenngu']?></a>
            </li>
            <li><span class="title">Năm sản xuất:</span> <a class="no_title" href="index.php?year=<?php echo $de['namsx']?>" title="Phim năm <?php echo $de['namsx']?>"><?php echo $de['namsx']?></a></li>
            <li>
                <span class="title">Đánh giá:</span> 
                <div class="star">
					<?php
						$rating = mysql_query("select AVG(diem) from rate,thongtinphim where rate.marate=thongtinphim.marate and thongtinphim.maphim = {$de['maphim']}");
						$rate_count = mysql_query("select * from rate,thongtinphim where rate.marate=thongtinphim.marate and thongtinphim.maphim = {$de['maphim']} group by rate.marate");
						$count = mysql_num_rows($rate_count);
						$r=mysql_fetch_array($rating);
						$diem=$r['AVG(diem)'];
						for($j=1;$j<=5;$j++)
						{
							if($j<$diem)
							{
								echo "<span class='star_on_png'></span>";
							}
							else
							{ 
								if(($j-0.5)<$diem)
									echo "<span class='star_half_png'></span>";
								else 
									echo "<span class='star_off_png'></span>";
							}
						}
						?>
            	</div><?php echo "&nbsp;(".$count." đánh giá )"?>
            </li>
            <li><span class="title">Ngày đăng phim:</span> <a class="no_title" href="index.php?date=<?php echo $de['ngaydang']?>" title="Phim <?php echo $de['ngaydang']?>"><?php echo $de['ngaydang']?></a></li>
            <li><span class="title">Ngày đăng tập mới:</span> <a class="no_title" href="index.php?date=<?php echo $de['ngaydangtapmoi']?>" title="Cập nhật tập phim mới <?php echo $de['ngaydang']?>"><?php echo $de['ngaydang']?></a></li>
        </ul>
    </div>
    <div class="clear"></div>
    <br>
    <center>Click +1 để giúp chúng tôi phục vụ bạn tốt hơn: 
        <div class="plusone">
            <div style="text-indent: 0px; margin: 0px; padding: 0px; background-color: transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; display: inline-block; width: 70px; height: 15px; background-position: initial initial; background-repeat: initial initial;" id="___plusone_0">
                <iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" style="position: static; top: 0px; width: 70px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 15px;" tabindex="0" vspace="0" width="100%" id="I0_1366097457835" name="I0_1366097457835" src="https://plusone.google.com/_/+1/fastbutton?bsv&amp;size=small&amp;hl=en-US&amp;origin=http%3A%2F%2Fphimsot.com&amp;url=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html&amp;ic=1&amp;jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.vi.AYAwafdhwHw.O%2Fm%3D__features__%2Fam%3DQQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTN_H8wUToi3itN6hQbQPH7kUWtqgw#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled&amp;id=I0_1366097457835&amp;parent=http%3A%2F%2Fphimsot.com&amp;rpctoken=18593734" allowtransparency="true" data-gapiattached="true" title="+1"></iframe>
            </div>
        </div>
        Chia sẻ phim này cho bạn bè:&nbsp;
        <a class="share_icon share_icon_facebook" onclick="popup_center('http://www.facebook.com/sharer.php?u=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html&amp;t=Phim+X%C3%B3m+G%C3%A0', 'Chia sẻ trên Facebook', 700, 500);return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html&amp;t=Phim+X%C3%B3m+G%C3%A0" title="Chia sẻ trên Facebook" target="_blank" rel="nofollow">
        <span class="ps_hidden">Chia sẻ trên Facebook</span></a>&nbsp;
        <a class="share_icon share_icon_google" onclick="popup_center('https://plus.google.com/share?url=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html', 'Chia sẻ trên Google+', 700, 500);return false;" href="https://plus.google.com/share?url=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html" title="Chia sẻ trên Google+" target="_blank" rel="nofollow">
        <span class="ps_hidden">Chia sẻ trên Google+</span></a>&nbsp;
        <a class="share_icon share_icon_zingme" onclick="popup_center('http://link.apps.zing.vn/share?url=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html&amp;t=Phim+X%C3%B3m+G%C3%A0', 'Chia sẻ trên Zing Me', 700, 500);return false;" href="http://link.apps.zing.vn/share?url=http%3A%2F%2Fphimsot.com%2Fphim%2Fxom-ga-m3675.html&amp;t=Phim+X%C3%B3m+G%C3%A0" title="Chia sẻ trên Zing Me" target="_blank" rel="nofollow">
        <span class="ps_hidden">Chia sẻ trên Zing Me</span></a>
        <div class="clear"></div><br>
        <a class="button button_20px" href="index.php?key=watch&id=<?php echo $de['maphim']?>&tentap=<?php echo $tapdautien['tentap'] ?>" title="Xem phim <?php echo $de['tenphim']?>">Xem phim »</a>
        <div class="clear"></div><br><br>
    </center>
    <br>
    <div class="ps_content">
        <div class="full">
        <?php echo $de['gioithieu']?>
        </div>    
    </div>
    <div class="ps_clear"></div><br><br>
    <!--<div class="fb-like-box fb_iframe_widget" data-href="http://www.facebook.com/phimsot" data-width="709" data-show-faces="false" data-stream="false" data-header="false" fb-xfbml-state="rendered">
        <span style="height: 62px; width: 709px;">
        <iframe id="f14d7c80b8" name="f310aabebc" scrolling="no" style="border: none; overflow: hidden; height: 62px; width: 709px;" class="fb_ltr" src="http://www.facebook.com/plugins/likebox.php?api_key=&amp;locale=vi_VN&amp;sdk=joey&amp;channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D21%23cb%3Df15191c7a8%26origin%3Dhttp%253A%252F%252Fphimsot.com%252Ff3a8583edc%26domain%3Dphimsot.com%26relation%3Dparent.parent&amp;height=62&amp;header=false&amp;show_faces=false&amp;stream=false&amp;width=709&amp;href=http%3A%2F%2Fwww.facebook.com%2Fphimsot&amp;colorscheme=light&amp;show_border=true"></iframe>
        </span>
    </div>
    <div class="fb-comments fb_iframe_widget" data-href="http://phimsot.com/xem-phim/my-nhan-ke-hau-truong-phim-m5823.html" data-num-posts="20" data-width="709" data-colorscheme="dark" fb-xfbml-state="rendered">
        <span style="height: 175px; width: 709px;"><iframe id="f14669945c" name="f36ceaf078" scrolling="no" style="border: none; overflow: hidden; height: 175px; width: 709px;" class="fb_ltr" src="https://www.facebook.com/plugins/comments.php?api_key=&amp;locale=vi_VN&amp;sdk=joey&amp;channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D21%23cb%3Df464d101c%26origin%3Dhttp%253A%252F%252Fphimsot.com%252Ff3a8583edc%26domain%3Dphimsot.com%26relation%3Dparent.parent&amp;colorscheme=dark&amp;numposts=20&amp;width=709&amp;href=http%3A%2F%2Fphimsot.com%2Fxem-phim%2Fmy-nhan-ke-hau-truong-phim-m5823.html"></iframe></span>
    </div>-->
    <div class="ps_clear"></div><br><br>
    <div class="tag"><b>Từ khóa tìm kiếm:</b> <a class="no_title" href="index.php?keyword=<?php echo $de['tenphim']?>"><?php echo $de['tenphim']?></a></div>
</div><!-- padding 10 -->
<?php }
include("include/film_list.php");
?>
